//
//  HMMainViewController.m
//  OC新浪微博
//
//  Created by wyman on 16/4/9.
//  Copyright © 2016年 wyman. All rights reserved.
//

#import "HMMainViewController.h"
#import "HMTabBar.h"
#import "HMBaseTableViewController.h"
#import "HMDiscoverViewController.h"
#import "HMHomeViewController.h"
#import "HMProfileViewController.h"
#import "HMMessageTableViewController.h"
@interface HMMainViewController ()

@end

@implementation HMMainViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    //添加导航控制器
   
    [self setChidrenControllers];
    
    
    HMTabBar *tabBar1 = [[HMTabBar alloc]init];
    [self setValue:tabBar1 forKeyPath:@"tabBar"];
    
    self.tabBar.tintColor = [UIColor orangeColor];
    
}


-(void)setChidrenControllers
{
    
    HMHomeViewController *homeVc = [[HMHomeViewController alloc]init];
    
    [self setChildrenInfo:homeVc withImage:@"tabbar_home" andtitle:@"首页"];
    
    
    
    HMMessageTableViewController *desVc = [[HMMessageTableViewController alloc]init];
    [self setChildrenInfo:desVc withImage:@"tabbar_message_center" andtitle:@"消息"];

    
    HMDiscoverViewController *mesVc = [[HMDiscoverViewController alloc]init];

    [self setChildrenInfo:mesVc withImage:@"tabbar_discover" andtitle:@"发现"];

    
    
    HMProfileViewController *proVc = [[HMProfileViewController alloc]init];

    [self setChildrenInfo:proVc withImage:@"tabbar_profile" andtitle:@"我"];

    
    
    


}

//私有方法

-(void)setChildrenInfo:(UITableViewController *)Vc withImage:(NSString *)imageName andtitle:(NSString *)title
{

    Vc.title = title;
    
    Vc.tabBarItem.image = [UIImage imageNamed:imageName];
    
    Vc.tabBarItem.selectedImage = [[UIImage imageNamed:[NSString stringWithFormat:@"%@%@",imageName,@"_selected"]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    
    UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:Vc];
    
    [self addChildViewController:nav];
    
    

}

@end
